<!DOCTYPE html>
<!-- saved from url=(0042)http://www.douban.com/group/topic/4450520/ -->
<html lang="zh-CN" class="ua-windows ua-webkit"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    

    <title>
    Java 垃圾回收策略调优，实践篇
</title>
    

    
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="Sun, 6 Mar 2005 01:00:00 GMT">
    
<meta http-equiv="mobile-agent" content="format=xhtml; url=http://m.douban.com/group/topic/4450520/">

    <script type="text/javascript" src="./Java 垃圾回收策略调优，实践篇_files/packed_ad3738113870.js" async="true"></script><script>var _head_start = new Date();</script>
    <script src="./Java 垃圾回收策略调优，实践篇_files/packed_jquery.min6301986802.js"></script>
    <script src="./Java 垃圾回收策略调优，实践篇_files/packed_douban1000047119.js"></script>
    <link href="./Java 垃圾回收策略调优，实践篇_files/packed_douban9785152125.css" rel="stylesheet" type="text/css">
    <style type="text/css">
    
        

    td, th { word-wrap: break-word; }
    .operation_div .lnk-delete-comment { display:none; }
    .operation_div .lnk-report { display:none; }
    .topic-doc { font-size:13px;line-height:1.62; }
    .topic-figure { text-align:center;color:#999;margin-bottom:2px; }
    .topic-figure img { max-width:500px; }
    .topic-figure-title { display:block; font-size:12px; }
    .clearfix {clear: both;}
    .clear {clear: both;}
    .topic-reply .user-face { float: left; width: 48px; height: 48px;margin-right:20px; overflow: hidden }
    .topic-reply li { margin: 0 0 20px 0;position:relative; }
    .topic-reply li .reply-doc { float:none;width:auto;overflow:hidden;zoom:1; }
    .reply-doc .pubtime { margin-left:1em; }
    .topic-content .from { margin-right:1em; }
    .reply-comment { width:98%;position:relative;padding:3px 4px;margin-bottom:5px;background-color:#e8eef2; }
    .reply-comment .lnk-close { position:absolute;right:10px;top:10px;font-weight:800;line-height:1.2;padding:0 2px; }
    .reply-comment .lnk-close:link { color:#999; }
    .reply-comment .lnk-close:hover { background-color:#999;color:#fff; }
    .reply-comment p { width:30em;padding:6px;margin:0; }
    .pubdate { white-space:nowrap;margin-left:10px; }
    .reply-quote { width:30em;padding-left:7px;margin:20px 0;border-left:1px solid;  }
    .reply-quote .all { display: none }
    .topic-reply li { margin-bottom:10px;background:#fff; }
    .operation_div { display:none;position:absolute;right:0;bottom:0; width:120px; text-align: right; }
    .operation_div a { margin-left:10px; }
    .operation_div a:link,
    .operation_div a:visited { color:#aaa; }
    .operation_div a:hover,
    .operation_div a:active { background-color:#aaa;color:#fff; }

    </style>
    
<link rel="stylesheet" type="text/css" href="./Java 垃圾回收策略调优，实践篇_files/packed_dialog4563741467.css">
<script type="text/javascript" src="./Java 垃圾回收策略调优，实践篇_files/packed_dialog8321689615.js"></script>
<style type="text/css">
.dui-dialog .bd { padding: 40px; font-size: 10pt; }
.dui-dialog .ft { background: #e4e4e4; height: 40px; }
.dui-dialog .ft div { padding-top: 15px; }
.dui-dialog .dui-dialog-prompt { float: left; }
.dui-dialog .bn-flat { color: #ffffff; float:right; width: 50px; }
.dui-dialog .btn-ok { background: #6fb45d; }
.dui-dialog .btn-cancel { background: #999999; }
</style>

    <link rel="stylesheet" href="http://img3.douban.com/misc/mixed_static/42fee8fab9cbebf5.css">
    <script></script>

    <link rel="shortcut icon" href="http://img3.douban.com/favicon.ico" type="image/x-icon">
<script src="./Java 垃圾回收策略调优，实践篇_files/ga.js" async="true"></script></head>
<body>
  

    <script type="text/javascript">var _body_start = new Date();</script>
    
   







<div id="db-global-nav" class="global-nav global-nav-a">
  <div class="bd">
    






<div class="top-nav-info">
    
    <a href="http://www.douban.com/accounts/login" rel="nofollow">登录</a>
    <a href="http://www.douban.com/accounts/register">注册</a>
</div>



    <div class="global-nav-items">
      <ul>
          
            
            <li class="on">
              <a href="http://www.douban.com/">豆瓣</a>
            </li>
          
            
            <li>
              <a href="http://book.douban.com/">读书</a>
            </li>
          
            
            <li>
              <a href="http://movie.douban.com/">电影</a>
            </li>
          
            
            <li>
              <a href="http://music.douban.com/">音乐</a>
            </li>
          
            
            <li>
              <a href="http://www.douban.com/location/">同城</a>
            </li>
          
            
            <li>
              <a href="http://read.douban.com/?dcs=top-nav&dcm=douban" target="_blank">阅读</a>
            </li>
          
            
            <li>
              <a href="http://douban.fm/" target="_blank">豆瓣FM</a>
            </li>
          
            <li>
              <a href="http://www.douban.com/group/topic/4450520/#more" class="bn-more"><span>更多</span></a>
              <div class="more-items">
                <table cellpadding="0" cellspacing="0">
                    
                    <tbody><tr><td><a href="http://9.douban.com/" target="_blank">九点</a></td></tr>
                    
                    <tr><td><a href="http://alphatown.com/" target="_blank">阿尔法城</a></td></tr>
                    
                    <tr><td><a href="http://www.douban.com/mobile/" target="_blank">移动应用</a></td></tr>
                </tbody></table>
              </div>
            </li>
      </ul>
    </div>
  </div>
</div>



   
    







<div id="db-nav-sns" class="nav">
  <div class="nav-wrap">
  <div class="nav-primary">

    <div class="nav-search">
      <form action="http://www.douban.com/search" method="get">
        <fieldset>
          <legend>搜索：</legend>
          <label for="inp-query">书籍、电影、音乐、小组、小站、成员</label>
          <div class="inp"><input id="inp-query" name="q" size="22" title="搜索书、电影、音乐、小组、小站、成员" maxlength="60" value=""></div>
          <div class="inp-btn"><input type="submit" value="搜索"></div>
        </fieldset>
      </form>
    </div>

    <div class="nav-logo">
      <a href="http://www.douban.com/">豆瓣社区</a>
    </div>

    <div class="nav-items">
     <ul>
      <li><a href="http://www.douban.com/">首页</a></li>
          <li><a href="http://www.douban.com/group/explore">发现小组</a></li>
          <li><a href="http://www.douban.com/explore/site/">发现小站</a></li>
          <li><a href="http://www.douban.com/online/">线上活动</a></li>
     </ul>
     </div>

  </div>
  </div>
</div>





    
    <div id="wrapper">
        

        
    <div id="content">
        
    









<div id="group-header-info">
    <img align="left" valign="top" class="groupicon head-icon-small" width="24" height="24" src="./Java 垃圾回收策略调优，实践篇_files/g10014-1.jpg" alt="Java&amp;Android移动应用编程">
    &nbsp; <a href="http://www.douban.com/group/java/?ref=1">Java&amp;Android移动应用编程小组</a>
        &nbsp; | &nbsp;
        <a href="http://www.douban.com/register?reason=join-group" class="j a_show_login" rel="nofollow">
              <span>加入小组</span>
        </a>
</div>


    <h1>
    Java 垃圾回收策略调优，实践篇
</h1>

    <div class="grid-16-8 clearfix">
        
        
        <div class="article">
	  
    
    <div class="topic-content clearfix">
        <div class="user-face">
            <a href="http://www.douban.com/people/1851090/"><img class="pil" src="./Java 垃圾回收策略调优，实践篇_files/u1851090-3.jpg" alt="KK"></a>
        </div>
        <div class="topic-doc">
            <h3>
                <span class="from">来自: <a href="http://www.douban.com/people/1851090/">KK</a></span>
                <span class="color-green">2008-10-22 13:26:30</span>
            </h3>

            
            <div id="link-report">

              <div class="topic-content">
                          
                          <p>JVM参数调优是一个很头痛的问题，可能和应用有关系，下面是本人一些调优的实践经验，希望对读者能有帮助，环境LinuxAS4,resin2.1.17,JDK6.0,2CPU,4G内存,dell2950服务器，网站是shedewang.com，新手可能觉得这文章没有用。
<br>
<br>一：串行垃圾回收，也就是默认配置，完成10万request用时153秒，JVM参数配置如下
<br>$JAVA_ARGS .= " -Dresin.home=$SERVER_ROOT -server -Xms2048M -Xmx2048M -Xmn512M -XX:PermSize=256M -XX:MaxPermSize=256M -XX:MaxTenuringThreshold=7 -XX:GCTimeRatio=19 -Xnoclassgc -Xloggc:log/gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps ";
<br>这种配置一般在resin启动24小时内似乎没有大问题，网站可以正常访问，但查看日志发现，在接近24小时时，Full GC执行越来越频繁，大约每隔3分钟就有一次Full GC，每次Full GC系统会停顿6秒左右，作为一个网站来说，用户等待6秒恐怕太长了，所以这种方式有待改善。MaxTenuringThreshold=7表示一个对象如果在救助空间移动7次还没有被回收就放入年老代，GCTimeRatio=19表示java可以用5%的时间来做垃圾回收，1/(1+19)=1 /20=5%。
<br> 
<br>二：并行回收，完成10万request用时117秒，配置如下：
<br>$JAVA_ARGS .= " -Dresin.home=$SERVER_ROOT -server -Xmx2048M -Xms2048M -Xmn512M -XX:PermSize=256M -XX:MaxPermSize=256M -Xnoclassgc -Xloggc:log/gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseParallelGC -XX:ParallelGCThreads=20 -XX:+UseParallelOldGC -XX:MaxGCPauseMillis=500 -XX:+UseAdaptiveSizePolicy -XX:MaxTenuringThreshold=7 -XX:GCTimeRatio=19 ";
<br>并行回收我尝试过多种组合配置，似乎都没什么用，resin启动3小时左右就会停顿，时间超过10 秒。也有可能是参数设置不够好的原因，MaxGCPauseMillis表示GC最大停顿时间，在resin刚启动还没有执行Full GC时系统是正常的，但一旦执行Full GC，MaxGCPauseMillis根本没有用，停顿时间可能超过20秒，之后会发生什么我也不再关心了，赶紧重启resin，尝试其他回收策略。
<br> 
<br>三：并发回收，完成10万request用时60秒，比并行回收差不多快一倍，是默认回收策略性能的2.5倍，配置如下：
<br>$JAVA_ARGS .= " -Dresin.home=$SERVER_ROOT -server -Xms2048M -Xmx2048M -Xmn512M -XX:PermSize=256M -XX:MaxPermSize=256M -XX:+UseConcMarkSweepGC -XX:MaxTenuringThreshold=7 -XX:GCTimeRatio=19 -Xnoclassgc -Xloggc:log/gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0 ";
<br>这个配置虽然不会出现10秒连不上的情况，但系统重启3个小时左右，每隔几分钟就会有5秒连不上的情况，查看gc.log，发现在执行ParNewGC时有个promotion failed错误，从而转向执行Full GC，造成系统停顿，而且会很频繁，每隔几分钟就有一次，所以还得改善。UseCMSCompactAtFullCollection是表是执行Full GC后对内存进行整理压缩，免得产生内存碎片，CMSFullGCsBeforeCompaction=N表示执行N次Full GC后执行内存压缩。
<br> 
<br>四：增量回收，完成10万request用时171秒，太慢了，配置如下
<br>$JAVA_ARGS .= " -Dresin.home=$SERVER_ROOT -server -Xms2048M -Xmx2048M -Xmn512M -XX:PermSize=256M -XX:MaxPermSize=256M -XX:MaxTenuringThreshold=7 -XX:GCTimeRatio=19 -Xnoclassgc -Xloggc:log/gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xincgc ";
<br>似乎回收得也不太干净，而且也对性能有较大影响，不值得试。
<br> 
<br>五：并发回收的I-CMS模式，和增量回收差不多，完成10万request用时170秒。
<br>$JAVA_ARGS .= " -Dresin.home=$SERVER_ROOT -server -Xms2048M -Xmx2048M -Xmn512M -XX:PermSize=256M -XX:MaxPermSize=256M -XX:MaxTenuringThreshold=7 -XX:GCTimeRatio=19 -Xnoclassgc -Xloggc:log/gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing -XX:CMSIncrementalDutyCycleMin=0 -XX:CMSIncrementalDutyCycle=10 -XX:-TraceClassUnloading ";
<br>采用了sun推荐的参数，回收效果不好，照样有停顿，数小时之内就会频繁出现停顿，什么sun推荐的参数，照样不好使。
<br> 
<br>六：递增式低暂停收集器，还叫什么火车式回收，不知道属于哪个系，完成10万request用时153秒
<br>$JAVA_ARGS .= " -Dresin.home=$SERVER_ROOT -server -Xms2048M -Xmx2048M -Xmn512M -XX:PermSize=256M -XX:MaxPermSize=256M -XX:MaxTenuringThreshold=7 -XX:GCTimeRatio=19 -Xnoclassgc -Xloggc:log/gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseTrainGC  ";
<br>该配置效果也不好，影响性能，所以没试。
<br> 
<br>七：相比之下，还是并发回收比较好，性能比较高，只要能解决ParNewGC（并行回收年轻代）时的promotion failed错误就一切好办了，查了很多文章，发现引起promotion failed错误的原因是CMS来不及回收（CMS默认在年老代占到90%左右才会执行），年老代又没有足够的空间供GC把一些活的对象从年轻代移到年老代，所以执行Full GC。CMSInitiatingOccupancyFraction=70表示年老代占到约70%时就开始执行CMS，这样就不会出现Full GC了。SoftRefLRUPolicyMSPerMB这个参数也是我认为比较有用的，官方解释是softly reachable objects will remain alive for some amount of time after the last time they were referenced. The default value is one second of lifetime per free megabyte in the heap，我觉得没必要等1秒，所以设置成0。配置如下
<br>$JAVA_ARGS .= " -Dresin.home=$SERVER_ROOT -server -Xms2048M -Xmx2048M -Xmn512M -XX:PermSize=256M -XX:MaxPermSize=256M -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=7 -XX:GCTimeRatio=19 -Xnoclassgc -XX:+DisableExplicitGC -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0 -XX:+CMSClassUnloadingEnabled -XX:-CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=70 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+PrintClassHistogram -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime -Xloggc:log/gc.log ";
<br>上面这个配置内存上升的很慢，24小时之内几乎没有停顿现象，最长的只停滞了0.8s，ParNew GC每30秒左右才执行一次，每次回收约0.2秒，看来问题应该暂时解决了。
<br>
<br>参数不明白的可以上网查，本人认为比较重要的几个参数是：-Xms -Xmx -Xmn MaxTenuringThreshold GCTimeRatio UseConcMarkSweepGC CMSInitiatingOccupancyFraction SoftRefLRUPolicyMSPerMB</p>

              </div>


            </div>
            

        </div>


        <div class="sns-bar" id="sep">
            <div class="sns-bar-rec">
                
            </div>
            <div class="sns-bar-fav">
                




        <span class="fav-num" data-tid="4450520" data-tkind="1013">
                    <a href="http://www.douban.com/group/topic/4450520/likes#sep">7人</a>
            喜欢
        </span>
            <a class="fav-add btn-fav j a_show_login" title="标为喜欢？" href="http://www.douban.com/accounts/register?reason=like" data-tid="4450520" data-tkind="1013">喜欢</a>

        <script>
        (typeof Do === 'function' ? Do : $).call(null, function(){
                if (typeof hasInitFavBtn !== 'undefined') {
                    return;
                }
                var fav_type = 'fav_note'; 
                var fav_url = 'http://www.douban.com/group/topic/4450520/likes#sep'; 
                hasInitFavBtn = 1;

                
var api_userlist = 'http://www.douban.com/j/like',
$win = $(window),
updateFavNum = function(node, n) {
  var p = node.parent(), favNum = p.find('.fav-num'), num;

  if (favNum.length === 0) {
  // 日记的情况
    favNum = p.find('.fav-num-note');
  }

  $('#fav-userlist').hide();
  if (favNum.length === 0) {
    favNum = $(['<span class="fav-num" data-tkind="', node.data('tkind'),'" data-tid="', node.data('tid'),'"><a href="' + fav_url + '">0人</a>喜欢</span>'].join(''));
    p.prepend(favNum);
  }

  num = parseInt(favNum.find('a').text(),10) + n;
  if (num === 0) {
    favNum.remove();
    return;
  }
  favNum.find('a').text(num + '人');
},
renderUserList = function(node, da) {
  if (!$.isArray(da)) {
    $('#fav-userlist').hide();
    return;
  }

  var i = 0, o, pos, h, htmlstr = ['<ul>'];
  if (da.length > 0){
      for (; o = da[i++]; ) {
        htmlstr.push([
         '<li>',
         '<a href="http://www.douban.com/people/', o.uid, '" target="_blank" class="pic"><img src="', o.icon_avatar,'" width="24" height="24"></a>',
         '<a href="http://www.douban.com/people/', o.uid, '" target="_blank">', o.screen_name,'</a>',
         '</li>'
        ].join(''));
      }
      htmlstr.push('</ul>');
  } else {
      htmlstr = ['<span>啊哦…喜欢这个的人都不愿意露脸</span>'];
  }


  node.removeClass('arrow-bottom').find('.bd').css({
    height: i > 9 ? 220 : 'auto',
    overflow: i > 9 ? 'auto' : 'hidden'
  }).html(htmlstr.join(''));

  pos = node.offset();
  h = node.height();

  if (pos.top - $win.scrollTop() + h > $win.height() - 40) {
    node.addClass('arrow-bottom').css('top', pos.top - h - 55);
  }
};

$('html').bind('click', function(e) {
  var list = $('#fav-userlist');
  if (list.length === 0 ||
      list.css('display') === 'none' ||
      e.target.tagName === 'A') {
    return;
  }
  if (!$.contains(list[0], e.target)) {
    list.hide();
  }
});

$('html').delegate('.fav-num a', 'click', function(e) {
  if (fav_type !== 'default') {
    return;
  }
  e.preventDefault();
  var el = $(e.currentTarget),
  pos = el.offset(),
  params = el.parent().data(),
  dataId = [params.tkind, params.tid].join(''),
  fav_user_list = $('#fav-userlist');

  if (fav_user_list.length === 0) {
    fav_user_list = $([
    '<div id="fav-userlist" class="fav-userlist">',
    '<div class="hd"><a href="" class="btn-close">X</a></div>',
    '<div class="bd">',
    '</div><i class="arrow"></i>',
    '</div>'
    ].join('')).appendTo('body');
    fav_user_list.find('.btn-close').click(function(e){
      e.preventDefault();
      fav_user_list.hide();
    });
  }

  fav_user_list.removeClass('arrow-bottom').
      find('.bd').
      css('height', 'auto').
      html('加载中...');

  fav_user_list.css({
    top: pos.top + 22,
    'margin-left': (function(con){
      return -1 * Math.floor(con.width()/2 - pos.left + con.offset().left) -10;
    })($('#content'))
  }).show();

  $.get(api_userlist,
  {
      tkind: params.tkind,
      tid: params.tid,
      alt: 'xd'
  },
  function(e){
    renderUserList(fav_user_list, e);
  }, 'jsonp');
});

            });
        </script>



            </div>
        </div>

    </div>

    


<div class="tabs" id="reviews">
  <a href="http://www.douban.com/group/topic/4450520/#sep" class="on">回应</a>
  <a href="http://www.douban.com/group/topic/4450520/likes#sep">喜欢</a>
</div>
            
    <ul class="topic-reply" id="comments">
        

<li class="clearfix comment-item" id="36481624" data-cid="36481624">
    <div class="user-face">
        <a href="http://www.douban.com/people/xds2000/"><img class="pil" src="./Java 垃圾回收策略调优，实践篇_files/u1065629-10.jpg" alt="肖"></a>
    </div>
    <div class="reply-doc content" style="padding-left:0px;">
        <div class="bg-img-green">
          <h4> 
                <a href="http://www.douban.com/people/xds2000/">肖</a> (@Beijing)
                <span class="pubtime">2008-10-22 22:53:34</span>
            </h4>
        </div>
        <p>首先使用64 bit os,是一个提高性能的不二法规.
<br>第二,任何调优应该有场景,在未知情况应该使用loggc导出日志分析,再加参数.对于参数的好与坏,我希望楼主能贴出更多的自已的思路</p>

        <div class="operation_div" id="1065629">
            <a href="http://www.douban.com/group/topic/4450520/?cid=36481624#last" class="lnk-reply">回应</a>
            <a rel="nofollow" href="javascript:void(0);" data-cid="36481624" class="lnk-delete-comment" title="真的要删除肖的发言?">删除</a>
        </div>
    </div>
</li>

        

<li class="clearfix comment-item" id="36890822" data-cid="36890822">
    <div class="user-face">
        <a href="http://www.douban.com/people/1851090/"><img class="pil" src="./Java 垃圾回收策略调优，实践篇_files/u1851090-3.jpg" alt="KK"></a>
    </div>
    <div class="reply-doc content" style="padding-left:0px;">
        <div class="bg-img-green">
          <h4> 
                <a href="http://www.douban.com/people/1851090/">KK</a>
                <span class="pubtime">2008-10-27 15:32:12</span>
            </h4>
        </div>
        <p>还有，如果遇到内存泄漏，要用jstack和jmap、jstat等多看看，应该可以找到问题，还要多看看gc日志各个区域内存使用情况和gc频率，这样才可以作出最佳配置。Good Luck</p>

        <div class="operation_div" id="1851090">
            <a href="http://www.douban.com/group/topic/4450520/?cid=36890822#last" class="lnk-reply">回应</a>
            <a rel="nofollow" href="javascript:void(0);" data-cid="36890822" class="lnk-delete-comment" title="真的要删除KK的发言?">删除</a>
        </div>
    </div>
</li>

        

<li class="clearfix comment-item" id="37459097" data-cid="37459097">
    <div class="user-face">
        <a href="http://www.douban.com/people/1851090/"><img class="pil" src="./Java 垃圾回收策略调优，实践篇_files/u1851090-3.jpg" alt="KK"></a>
    </div>
    <div class="reply-doc content" style="padding-left:0px;">
        <div class="bg-img-green">
          <h4> 
                <a href="http://www.douban.com/people/1851090/">KK</a>
                <span class="pubtime">2008-11-03 17:37:21</span>
            </h4>
        </div>
        <p>内存问题和应用有很大关系，我的应用因为用到了缓存，所以年老代比较大，多看看gc日志，出了问题多用Jstack,jmap等工具查看，这样才可以最大的优化JVM参数。经过进两个星期的调试，我的配置是/usr/local/jdk/bin/java -Dresin.home=/usr/local/resin -server -Xms1800M -Xmx1800M -Xmn300M -Xss512K -XX:PermSize=300M -XX:MaxPermSize=300M -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=5 -XX:GCTimeRatio=19 -Xnoclassgc -XX:+DisableExplicitGC -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0 -XX:-CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=70 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+PrintClassHistogram -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -Xloggc:log/gc.log
<br>72小时之内没有一点停顿，我是32位LinuxAS4操作系统。</p>

        <div class="operation_div" id="1851090" style="display: none;">
            <a href="http://www.douban.com/group/topic/4450520/?cid=37459097#last" class="lnk-reply">回应</a>
            <a rel="nofollow" href="javascript:void(0);" data-cid="37459097" class="lnk-delete-comment" title="真的要删除KK的发言?">删除</a>
        </div>
    </div>
</li>

        

<li class="clearfix comment-item" id="37459727" data-cid="37459727">
    <div class="user-face">
        <a href="http://www.douban.com/people/foxswily/"><img class="pil" src="./Java 垃圾回收策略调优，实践篇_files/u1341804-1.jpg" alt="Foxswily"></a>
    </div>
    <div class="reply-doc content" style="padding-left:0px;">
        <div class="bg-img-green">
          <h4> 
                <a href="http://www.douban.com/people/foxswily/">Foxswily</a>
                <span class="pubtime">2008-11-03 17:45:09</span>
            </h4>
        </div>
        <p>mark先，前一段做一个对性能要求高的项目，典型的高DB负载，把着眼点都放在了DB优化上(最终效果也不错，大概提高了40倍左右的性能)，一直没有考虑jvm优化，疏忽了。
<br>but，jvm的优化性价比貌似不是很高，化很大力气得到回报如何有待实践检验。</p>

        <div class="operation_div" id="1341804" style="display: none;">
            <a href="http://www.douban.com/group/topic/4450520/?cid=37459727#last" class="lnk-reply">回应</a>
            <a rel="nofollow" href="javascript:void(0);" data-cid="37459727" class="lnk-delete-comment" title="真的要删除Foxswily的发言?">删除</a>
        </div>
    </div>
</li>

        

<li class="clearfix comment-item" id="37460534" data-cid="37460534">
    <div class="user-face">
        <a href="http://www.douban.com/people/1851090/"><img class="pil" src="./Java 垃圾回收策略调优，实践篇_files/u1851090-3.jpg" alt="KK"></a>
    </div>
    <div class="reply-doc content" style="padding-left:0px;">
        <div class="bg-img-green">
          <h4> 
                <a href="http://www.douban.com/people/1851090/">KK</a>
                <span class="pubtime">2008-11-03 17:55:02</span>
            </h4>
        </div>
        <p>不是纯粹性能问题，到一定时候JVM参数必须优化，不然访问量大的时候会造成频繁的Full GC或者CMS，Full GC有时能让整个系统停顿10秒，10秒内用户的任何点击都在等待状态，要是隔2分钟就来一次Full GC，恐怕用户和老板都受不了了。
<br>
<br>并发回收如果配置的不好照样会产生Full GC。:)</p>

        <div class="operation_div" id="1851090">
            <a href="http://www.douban.com/group/topic/4450520/?cid=37460534#last" class="lnk-reply">回应</a>
            <a rel="nofollow" href="javascript:void(0);" data-cid="37460534" class="lnk-delete-comment" title="真的要删除KK的发言?">删除</a>
        </div>
    </div>
</li>

        

<li class="clearfix comment-item" id="37460849" data-cid="37460849">
    <div class="user-face">
        <a href="http://www.douban.com/people/foxswily/"><img class="pil" src="./Java 垃圾回收策略调优，实践篇_files/u1341804-1.jpg" alt="Foxswily"></a>
    </div>
    <div class="reply-doc content" style="padding-left:0px;">
        <div class="bg-img-green">
          <h4> 
                <a href="http://www.douban.com/people/foxswily/">Foxswily</a>
                <span class="pubtime">2008-11-03 17:58:43</span>
            </h4>
        </div>
        <p>有道理，支持这种有内容、有见地的讨论贴。</p>

        <div class="operation_div" id="1341804" style="display: none;">
            <a href="http://www.douban.com/group/topic/4450520/?cid=37460849#last" class="lnk-reply">回应</a>
            <a rel="nofollow" href="javascript:void(0);" data-cid="37460849" class="lnk-delete-comment" title="真的要删除Foxswily的发言?">删除</a>
        </div>
    </div>
</li>

        

<li class="clearfix comment-item" id="347193386" data-cid="347193386">
    <div class="user-face">
        <a href="http://www.douban.com/people/lozen/"><img class="pil" src="./Java 垃圾回收策略调优，实践篇_files/u2684172-6.jpg" alt="洛臻星轮"></a>
    </div>
    <div class="reply-doc content" style="padding-left:0px;">
        <div class="bg-img-green">
          <h4> 
                <a href="http://www.douban.com/people/lozen/">洛臻星轮</a> (一切随意 所以 没关系)
                <span class="pubtime">2012-05-22 23:22:11</span>
            </h4>
        </div>
        <p>感谢下，用了里面的很多参数，目前好使了，让它再多跑跑
<br>项目中Full GC一次停顿了个快十秒，一停顿事件就积压，隔段时间又停顿，事件积压得越来越严重，程序就崩了...</p>

        <div class="operation_div" id="2684172" style="display: none;">
            <a href="http://www.douban.com/group/topic/4450520/?cid=347193386#last" class="lnk-reply">回应</a>
            <a rel="nofollow" href="javascript:void(0);" data-cid="347193386" class="lnk-delete-comment" title="真的要删除洛臻星轮的发言?">删除</a>
        </div>
    </div>
</li>

        

<li class="clearfix comment-item" id="364769409" data-cid="364769409">
    <div class="user-face">
    </div>
    <div class="reply-doc content" style="padding-left:0px;">
        <div class="bg-img-green">
          <h4> 
                <a href="http://www.douban.com/people/55956054/">alzq</a>
                <span class="pubtime">2012-07-20 13:00:19</span>
            </h4>
        </div>
        <p>好配置，实验中……效果不错～</p>

        <div class="operation_div" id="55956054">
            <a href="http://www.douban.com/group/topic/4450520/?cid=364769409#last" class="lnk-reply">回应</a>
            <a rel="nofollow" href="javascript:void(0);" data-cid="364769409" class="lnk-delete-comment" title="真的要删除alzq的发言?">删除</a>
        </div>
    </div>
</li>

    </ul>

            


            
    
    <h2>
        你的回应
            &nbsp;·&nbsp;·&nbsp;·&nbsp;·&nbsp;·&nbsp;·
    </h2>

    <span class="pl3" align="right">
        回应请先
        <a class="j a_show_login" href="http://www.douban.com/accounts/register?reason=discuss">登录</a>
        , 或
        <a href="http://www.douban.com/accounts/register?reason=discuss">注册</a>
    </span>
    <div class="txd">
        <form action="http://www.douban.com/group/topic/4450520/no_where_to_go">
            <textarea readonly="" id="last" class="j a_show_login" name="rv_comment" rows="8" cols="54"></textarea><br>
            <input name="submit_btn" type="submit" class="j a_show_login" value="加上去">
        </form>
    </div>


        
    
    

    



        <div class="topic-similar-groups">
                





    
        <div class="clear"></div>
        
    <h2>
        这个小组的成员也喜欢去
            &nbsp;·&nbsp;·&nbsp;·&nbsp;·&nbsp;·&nbsp;·
    </h2>

        <div>
            




    
    <dl class="ob">
        <dt><a href="http://www.douban.com/group/eclipse/"><img src="./Java 垃圾回收策略调优，实践篇_files/g18754-1.jpg" class="m_sub_img" alt="eclipse"></a></dt>
    
    <dd><a title="eclipse" href="http://www.douban.com/group/eclipse/">eclipse</a> <span>(3784)</span>
    </dd>
    </dl>
    
    <dl class="ob">
        <dt><a href="http://www.douban.com/group/open-source/"><img src="./Java 垃圾回收策略调优，实践篇_files/g13404-1.jpg" class="m_sub_img" alt="开源"></a></dt>
    
    <dd><a title="开源" href="http://www.douban.com/group/open-source/">开源</a> <span>(4976)</span>
    </dd>
    </dl>
    
    <dl class="ob">
        <dt><a href="http://www.douban.com/group/developers/"><img src="./Java 垃圾回收策略调优，实践篇_files/g10051-2.jpg" class="m_sub_img" alt="程序员"></a></dt>
    
    <dd><a title="程序员" href="http://www.douban.com/group/developers/">程序员</a> <span>(4599)</span>
    </dd>
    </dl>
    
    <dl class="ob">
        <dt><a href="http://www.douban.com/group/programmer/"><img src="./Java 垃圾回收策略调优，实践篇_files/g10367-2.jpg" class="m_sub_img" alt="程序员书屋"></a></dt>
    
    <dd><a title="程序员书屋" href="http://www.douban.com/group/programmer/">程序员书屋</a> <span>(12431)</span>
    </dd>
    </dl>
    
    <dl class="ob">
        <dt><a href="http://www.douban.com/group/ThinkingInJava/"><img src="./Java 垃圾回收策略调优，实践篇_files/g113146-4.jpg" class="m_sub_img" alt="Thinking In Java"></a></dt>
    
    <dd><a title="Thinking In Java" href="http://www.douban.com/group/ThinkingInJava/">Thinking In Java</a> <span>(3018)</span>
    </dd>
    </dl>
    
    <dl class="ob">
        <dt><a href="http://www.douban.com/group/15620/"><img src="./Java 垃圾回收策略调优，实践篇_files/g15620-1.jpg" class="m_sub_img" alt="Java Swing"></a></dt>
    
    <dd><a title="Java Swing" href="http://www.douban.com/group/15620/">Java Swing</a> <span>(1455)</span>
    </dd>
    </dl>









        </div>



        </div>

        









	</div>
        <div class="aside">
            

    <p class="pl2">&gt; <a href="http://www.douban.com/group/java/">回Java&amp;Android移动应用编程小组</a></p><br> 

    <!-- douban ad begin -->
    <div id="group_topic_new_top_right2"></div>
    <div id="dale_group_topic_new_top_right"><iframe id="dale_group_topic_new_top_right_frame" frameborder="0" scrolling="no" style="overflow: hidden; margin: 0px 0px 20px;" width="300" height="250"></iframe></div>
    <!-- douban ad end -->

    
        
    <h2>
        最新话题
            &nbsp;·&nbsp;·&nbsp;·&nbsp;·&nbsp;·&nbsp;·
    </h2>

        <div class="indent">
                <p class="pl ul"><a href="http://www.douban.com/group/topic/35802641/" title="【招聘】深圳~java工程师">【招聘】深圳~java工程师</a> &nbsp;
                <span class="pl">(lost my Severn) </span></p>
                <p class="pl ul"><a href="http://www.douban.com/group/topic/35303849/" title="Android电子书资源，需要的可看下">Android电子书资源，需要的可看下</a> &nbsp;
                <span class="pl">(bingge) </span></p>
                <p class="pl ul"><a href="http://www.douban.com/group/topic/33700856/" title="Android开发教程与视频教程类专题资料免费下载整理合集">Android开发教程与视频教程类专题资料免费下载整理...</a> &nbsp;
                <span class="pl">(dblibrary) </span></p>
                <p class="pl ul"><a href="http://www.douban.com/group/topic/34898274/" title="java视频教程">java视频教程</a> &nbsp;
                <span class="pl">(北风吹网) </span></p>
                <p class="pl ul"><a href="http://www.douban.com/group/topic/35880813/" title="高薪招聘-无锡Java">高薪招聘-无锡Java</a> &nbsp;
                <span class="pl">(Vina cheney) </span></p>
                <p class="pl ul"><a href="http://www.douban.com/group/topic/35880763/" title="招聘无锡Java">招聘无锡Java</a> &nbsp;
                <span class="pl">(Vina cheney) </span></p>
                <p class="pl ul"><a href="http://www.douban.com/group/topic/35835334/" title="【北京旅信顺捷】招聘Android软件工程师">【北京旅信顺捷】招聘Android软件工程师</a> &nbsp;
                <span class="pl">(strongtec) </span></p>
                <p class="pl ul"><a href="http://www.douban.com/group/topic/34278212/" title="【招聘】坐标：帝都三元桥--诚聘Android软件开发工程师">【招聘】坐标：帝都三元桥--诚聘Android软件开发工...</a> &nbsp;
                <span class="pl">(花棉裤) </span></p>
        </div>


    


    
    
        <h2 class="usf">全站热点话题:</h2>
        <div class="indent">
                    <p class="pl ul">
                    <a href="http://www.douban.com/group/topic/20312050/?r=1" title="【转】【完结】减肥三步曲（养生观点，根除肥胖）">【转】【完结】减肥三步曲（养生观点，根...</a> &nbsp;
                            <span class="pl">249回应</span>
                    </p>
                    <p class="pl ul">
                    <a href="http://www.douban.com/group/topic/35520730/?r=1" title="柬埔寨、泰国、马来西亚、新加坡，60天5000元窮游四國…~\(≧▽≦)/~">柬埔寨、泰国、马来西亚、新加坡，60天500...</a> &nbsp;
                            <span class="pl">101回应</span>
                    </p>
                    <p class="pl ul">
                    <a href="http://www.douban.com/group/topic/4342204/?r=1" title="猜猜楼下的是什么星座!被猜中了的那个他(她)找猜的那个他(她)要QQ号">猜猜楼下的是什么星座!被猜中了的那个他(...</a> &nbsp;
                            <span class="pl">7157回应</span>
                    </p>
                    <p class="pl ul">
                    <a href="http://www.douban.com/group/topic/16801263/?r=1" title="流浪吧！！！2011奔赴远方。。">流浪吧！！！2011奔赴远方。。</a> &nbsp;
                            <span class="pl">160回应</span>
                    </p>
                    <p class="pl ul">
                    <a href="http://www.douban.com/group/topic/27933900/?r=1" title="¤你的负担将变成礼物，你的苦将照亮你的路。">¤你的负担将变成礼物，你的苦将照亮你的路。</a> &nbsp;
                            <span class="pl">494回应</span>
                    </p>
                    <p class="pl ul">
                    <a href="http://www.douban.com/group/topic/35524131/?r=1" title="！有没有！想去【刺青】又不敢的！！福利来了！！！！！！！">！有没有！想去【刺青】又不敢的！！福利...</a> &nbsp;
                            <span class="pl">496回应</span>
                    </p>
                    <p class="pl ul">
                    <a href="http://www.douban.com/group/topic/35913583/?r=1" title="创作裁子王力宏与各国歌手经典对唱无缝对接">创作裁子王力宏与各国歌手经典对唱无缝对接</a> &nbsp;
                            <span class="pl">70回应</span>
                    </p>
                    <p class="pl ul">
                    <a href="http://www.douban.com/group/topic/35895952/?r=1" title="我那败家人造美女的表妹如何失去了她的真爱">我那败家人造美女的表妹如何失去了她的真爱</a> &nbsp;
                            <span class="pl">382回应</span>
                    </p>
        </div>
    


    <!-- douban app begin -->
    
    





<div class="mobile-app-entrance block5 app-group">

    <a class="entrance-link first-link" href="http://www.douban.com/mobile/group">
        <span class="app-icon icon-group"></span>
        <span class="main-title">豆瓣小组手机客户端</span>
        <span class="sub-title">轻轻松松看小组，随时随地聊话题</span>
    </a>
</div>

    <!-- douban app end -->

        </div>
        <div class="extra">
            

        </div>
    </div>
    </div>

        
    <div id="footer">
        

<span id="icp" class="fleft gray-link">
    © 2005－2013 douban.com, all rights reserved
</span>

<span class="fright">
    <a href="http://www.douban.com/about">关于豆瓣</a>
    · <a href="http://www.douban.com/jobs">在豆瓣工作</a>
    · <a href="http://www.douban.com/about?topic=contactus">联系我们</a>
    · <a href="http://www.douban.com/about?policy=disclaimer">免责声明</a>
    
    · <a href="http://www.douban.com/help/">帮助中心</a>
    · <a href="http://developers.douban.com/" target="_blank">开发者</a>
    · <a href="http://www.douban.com/mobile/">移动应用</a>
    · <a href="http://www.douban.com/partner/">豆瓣广告</a>
</span>


    </div>

    </div>
    <script type="text/javascript" src="./Java 垃圾回收策略调优，实践篇_files/7aa9698851728be.js"></script>
    

<div class="back-to-top" style="left: 894.5454406738281px; position: fixed; bottom: 0px; display: none;">
    <a href="http://www.douban.com/group/topic/4450520/#" style="top: 40px;">↑回顶部</a>
</div>
<script>
Do(function(){var h=$(window);var k=$(document);var l;var a=$(".back-to-top");var b=$(".topic-reply");var g;var i=$("#content");var d=$.browser.msie&&$.browser.version==="6.0";var f=function(n){if(!f.cache){f.cache=[]}if(f.cache[n]){return}var m=new Date;(new Image()).src="/stat.html?source=group&action=back_top&iden="+n+"&month="+(m.getMonth()+1)+"&day="+m.getDate()+"&timestamp="+(+new Date);f.cache[n]=1};var e=function(){if(e.value){return e.value}return i.offset().top+i.height()};h.load(function(){e.value=e()});var c=function(m){if(m+g>=e()){a.css({position:"absolute",bottom:"",top:e()-a.outerHeight()})}else{if(!d){a.css({position:"fixed",top:"",bottom:0})}}a.show().find("a").stop().animate({top:0});f("show")};var j=function(){a.hide().find("a").css("top",40)};h.resize(function(){g=h.height();a.css("left",b.offset().left+b.width()+60);l=k.height()/g>3?Math.max(2*g,$(".aside").height()):0});h.trigger("resize");h.scroll((function(){var m;return function(){if(m){clearTimeout(m)}setTimeout(function(){if(l===0){return}var n=k.scrollTop();if(n>l){c(n)}else{j()}},100)}})());a.find("a").click(function(m){m.preventDefault();k.scrollTop(0);f("use")});if(d){h.scroll(function(){if(k.scrollTop()+g>=e()){return}a.css("top",k.scrollTop()+g-a.height())})}});
Do(function() {
  function removeComment(obj, cid){
    $.post_withck("/j/group/topic/4450520/remove_comment",{cid:cid}, function(d){
      d = $.parseJSON(d);
      if(d.r == 0){
        if(d.manager){
          window.location = d.url;
        }else{
          location.reload();
        }
      }else{
        alert(d.err_msg);
      }
    });
  }

  $('.reply-quote .toggle-reply').click(function(e) {
    e.preventDefault();
    var el = $(this);
    el.prevAll('span').toggle();
    el.find('span').toggle();
  });

  $('.lnk-delete-comment').click(function(){
    if(confirm($(this).attr('title'))){
      var o = $(this);
      var comment = o.closest('.comment-item');
      var cid = $(this).attr("data-cid");
      removeComment(comment, cid);
    }
    return false;
  });

  /* common dialog generator */
  function generate_group_prompt_dialog(dui_config){
    var prompt_dlg = dui.Dialog({
        title: (dui_config.title? dui_config.title: '操作提示'),
        content: (dui_config.content? dui_config.content: '操作内容'),
        width: (dui_config.width? dui_config.width: 400),
        buttons: [
            {text: '确定', method: function(){} }
        ]
    });
    var dui_dialog_ft_html = function(dui_config){
        if(dui_config.callback){
            $('.dui-dialog').delegate('.btn-ok', 'click', function(){
                dui_config.callback();
            });
        }
        $('.dui-dialog').delegate('.btn-cancel', 'click', function(){
            $(".dui-dialog").hide();
        });
        return '<div><span class="dui-dialog-prompt"><label><input type="checkbox" ' + (dui_config.checked? 'checked=checked ': '') + '/>' + dui_config.prompt + '</label></span><span class="bn-flat btn-cancel">取消</span><span class="bn-flat btn-ok">确定</span></div>';
    };
    prompt_dlg.open();
    prompt_dlg.node.find('.ft').html(dui_dialog_ft_html(dui_config));
  }
  /* common over */
  $('.ban-dialog-confirm').click(function(){
    var ban_action = function(){
        var ban_url = $('.ban-dialog-confirm').attr('href');
        var remove_topic_url = $('.remove-dialog-confirm').attr('href');
        console.log(ban_url);
        $.post(ban_url, {timestamp: (new Date()).getTime()}, function(d){
            $('.ban-dialog-confirm').closest('span').addClass('pl').html('已封禁');
        });
        if($('.dui-dialog-prompt input').attr('checked')){
            window.location = remove_topic_url;
        }
        $('.dui-dialog').hide();
    };
    generate_group_prompt_dialog({content: '真的要把KK永久封禁？', prompt:'同时删除此话题', checked: true, callback: ban_action});
    return false;
  });
  $('.remove-dialog-confirm').click(function(){
    var remove_action = function(){
        var ban_url = $('.ban-dialog-confirm').attr('href');
        var remove_topic_url = $('.remove-dialog-confirm').attr('href');
        if($('.dui-dialog-prompt input').attr('checked')){
            $.post(ban_url, {timestamp: (new Date()).getTime()});
        }
        window.location = remove_topic_url;
    };
    generate_group_prompt_dialog({content: '真的要删除小组话题 Java 垃圾回收策略调优，实践篇？', prompt:'同时封禁该成员', callback: remove_action});
    return false;
  });
});
</script>
    <!-- douban ad begin -->
    
    




<script type="text/javascript">
    (function (global) {
        var newNode = global.document.createElement('script'),
            existingNode = global.document.getElementsByTagName('script')[0],
            adSource = 'http://erebor.douban.com/',
            userId = '',
            browserId = 'c4JVxo/zz1k',
            ipAddress = '218.249.60.68',
            criteria = '1:10014|2:Android|3:/group/topic/4450520/',
            preview = '',
            debug = false,
            adSlots = ['dale_group_topic_new_top_right', 'group_topic_new_top_right2'];

        global.DoubanAdRequest = {src: adSource, uid: userId, bid: browserId, ip: ipAddress, crtr: criteria, prv: preview, debug: debug};
        global.DoubanAdSlots = (global.DoubanAdSlots || []).concat(adSlots);

        newNode.setAttribute('type', 'text/javascript');
        newNode.setAttribute('src', 'http://img3.douban.com/js/packed_ad3738113870.js');
        newNode.setAttribute('async', true);
        existingNode.parentNode.insertBefore(newNode, existingNode);
    })(this);
</script>




    <!-- douban ad end -->


    
    
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-7019765-1']);
_gaq.push(['_addOrganic', 'baidu', 'word']);
_gaq.push(['_addOrganic', 'soso', 'w']);
_gaq.push(['_addOrganic', '3721', 'name']);
_gaq.push(['_addOrganic', 'youdao', 'q']);
_gaq.push(['_addOrganic', 'so.360.cn', 'q']);
_gaq.push(['_addOrganic', 'vnet', 'kw']);
_gaq.push(['_addOrganic', 'sogou', 'query']);
_gaq.push(['_addIgnoredOrganic', '豆瓣']);
_gaq.push(['_addIgnoredOrganic', 'douban']);
_gaq.push(['_addIgnoredOrganic', '豆瓣网']);
_gaq.push(['_addIgnoredOrganic', 'www.douban.com']);
_gaq.push(['_setDomainName', '.douban.com']);


    _gaq.push(['_setCustomVar', 1, 'responsive_view_mode', 'desktop', 3]); 

_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);


window._ga_init = function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
};
if (window.addEventListener) {
    window.addEventListener('load', _ga_init, false);
} else {
    window.attachEvent('onload', _ga_init);
}
</script>








    <!-- gardner7-->



<script>var _check_hijack = function () {
            var _sig = "c4JVxo/z", _login = false, bid = get_cookie('bid');
            if (location.protocol != "file:" && (typeof(bid) != "string" && _login || typeof(bid) == "string" && bid.substring(0,8) != _sig)) {
                location.href+=(/\?/.test(location.href)?"&":"?") + "_r=" + Math.random().toString(16).substring(2);
            }};
            if (typeof(Do) != 'undefined') Do(_check_hijack);
            else if (typeof(get_cookie) != 'undefined') _check_hijack();
            </script>
















































</body></html>